#include "RbnCellController.h"

#include <string.h>

/*
	RbnCellController
*/

/*	public	*/

RbnCellController::RbnCellController(Rbn* rbn) :
	_rbn(rbn) {

	/* outputs */
	int outputSize = rbn->getOutputSize();
	_outputs = new double[outputSize];
	memset(_outputs, 0, outputSize * sizeof(double));
}

RbnCellController::~RbnCellController() {
	/* rbn */
	delete _rbn;

	/* outputs */
	delete[] _outputs;
}

void RbnCellController::update() {
	_rbn->update();

	/* update output double array */
	int outputSize  = _rbn->getOutputSize();
	int* rbnOutputs = _rbn->getOutputs();
	for(int i = 0; i != outputSize; ++i) {
		_outputs[i] = rbnOutputs[i];
	}
}

int RbnCellController::getOutputSize() const {
	return _rbn->getOutputSize();
}

double const* RbnCellController::getOutputAddress(int index) const {
	return &(_outputs[index]);
}

